import java.io.IOException;
import java.net.DatagramSocket;
import java.net.DatagramPacket;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;


public class OMHT implements Runnable{
	//attributes
	Thread outThread;
	DatagramSocket socket;
	ArrayBlockingQueue<DatagramPacket> queue;
	
	//constructors
	public OMHT(){
		this.queue = null;
		this.socket = null;		
	}
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public OMHT(Queue queue, DatagramSocket socket){
		this.queue = (ArrayBlockingQueue<DatagramPacket>) queue;
		this.socket = socket;
		outThread = new Thread();
		outThread.start();
	}
	
	//methods
	@SuppressWarnings("rawtypes")
	public Queue getQueue(){
		return queue;
	}
		//accessors
		//mutators

	@Override
	public void run() {
		DatagramPacket pkt;
		while(true){
			try{
				//get data from send method
				pkt = queue.take();
				socket.send(pkt);
			}
			catch(InterruptedException e){
				e.printStackTrace();
			}
			catch (IOException e){
				e.printStackTrace();
			}
		}
	}
	

}
